#include "dmxinterface.h"

#include "qdebug.h"

bool DmxInterface::m_dllLoaded = false;
int DmxInterface::m_numOfChannels = 0;

const int MAX_MOCK_VALUES = 6;
static double lightValues[MAX_MOCK_VALUES];

bool DmxInterface::startDmxService(int numberOfChannels)
{
   m_numOfChannels = numberOfChannels;
   m_dllLoaded = true;

   return m_dllLoaded;
}

void DmxInterface::stopDmxService()
{
   m_dllLoaded = false;
}

void DmxInterface::setValueForChannel( double value, int channel)
{
   if (channel < MAX_MOCK_VALUES)
   {
      lightValues[channel] = value;
      qDebug() << "DMX ch: " << channel << "    val: " << value;
   }
   else
   {
      qDebug() << "DMX invalid channel: " << channel;
   }
}

void DmxInterface::setValueForAllChannels(QList<double> values)
{
   for (int i=0; i < values.length(); i++)
   {
      setValueForChannel( values.at(i), i);
   }
}

void DmxInterface::turnAllChannelsOff()
{
   for (int i=0; i < m_numOfChannels; i++)
   {
      setValueForChannel( 0, i);
   }
}
